package com.kylinhunter.ui.common.dialog;

import java.awt.Component;

import javax.swing.JOptionPane;

import com.kylinhunter.ch.language.LangChangeListener;
import com.kylinhunter.ch.language.ResourceManager;
import com.kylinhunter.exception.KHException;

public class DialogTools   implements LangChangeListener  {
	public static final int YES_OPTION=JOptionPane.YES_OPTION;
	public static final int NO_OPTION=JOptionPane.NO_OPTION;
	private String error_Title=""; 
	private String warning_Title="";
	private String information_Title="";
	private String input_Title="";
	private String confirm_Title="";
	public   void showWarningMessage(Component parentComponent,	Object message){
		JOptionPane.showMessageDialog(parentComponent, message, this.warning_Title, JOptionPane.WARNING_MESSAGE);
	}
	public   void showErrorMessage(Component parentComponent,	Object message){
		JOptionPane.showMessageDialog(parentComponent, message, this.error_Title, JOptionPane.ERROR_MESSAGE);
	}
	
	public   void showErrorMessage(Component parentComponent,	KHException ex){
		JOptionPane.showMessageDialog(parentComponent, ex.getErrorMessage(), this.error_Title, JOptionPane.ERROR_MESSAGE);
	}
	public   void showInformationMessage(Component parentComponent,		Object message){
		JOptionPane.showMessageDialog(parentComponent, message, this.information_Title, JOptionPane.INFORMATION_MESSAGE);
	}
	public      int showConfirmDialog_Yes_No(Component parentComponent,Object message ){
		return JOptionPane.showConfirmDialog(parentComponent, message, this.confirm_Title,JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
	}
	
	public     String showInputDialog(Component parentComponent, Object message) {
		return  JOptionPane.showInputDialog(parentComponent,message, this.input_Title,	JOptionPane.INFORMATION_MESSAGE);
	}
	
	
	public String getError_Title() {
		return error_Title;
	}
	public void setError_Title(String errorTitle) {
		error_Title = errorTitle;
	}
	public String getWarning_Title() {
		return warning_Title;
	}
	public void setWarning_Title(String warningTitle) {
		warning_Title = warningTitle;
	}
	public String getInput_Title() {
		return input_Title;
	}
	public void setInput_Title(String inputTitle) {
		input_Title = inputTitle;
	}
	public String getConfirm_Title() {
		return confirm_Title;
	}
	public void setConfirm_Title(String confirmTitle) {
		confirm_Title = confirmTitle;
	}
	
	public String getInformation_Title() {
		return information_Title;
	}
	public void setInformation_Title(String informationTitle) {
		information_Title = informationTitle;
	}
	@Override
	public void updateResource(ResourceManager resourceManager) {
		// TODO Auto-generated method stub
		this.error_Title=resourceManager.getString(ResourceManager.SYS_RESOURCE_FILE,"common.error.Title");
		this.warning_Title=resourceManager.getString(ResourceManager.SYS_RESOURCE_FILE,"common.warning.Title");
		this.confirm_Title=resourceManager.getString(ResourceManager.SYS_RESOURCE_FILE,"common.confirm.Title");
		this.input_Title=resourceManager.getString(ResourceManager.SYS_RESOURCE_FILE,"common.input.Title");
		information_Title=resourceManager.getString(ResourceManager.SYS_RESOURCE_FILE,"common.information.Title");
	}
}
